﻿using System.IO;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Strom.Core.Graphic.Sprite
{
    public abstract class Sprite
    {
        readonly Bitmap[,] _animations = new Bitmap[4,4];

        public void FillAnimationsFromRMXP(Bitmap RMXPsource)
        {
            int animSizeX = RMXPsource.Width/4;
            int animSizeY = RMXPsource.Height/4;

            for (int yp = 0; yp < 4; yp++)
            {
                for (int xp = 0; xp < 4; xp++)
                {
                    _animations[yp, xp] =
                        RMXPsource.Clone(new Rectangle(animSizeX*xp, animSizeY*yp, animSizeX, animSizeY),
                                         PixelFormat.DontCare);
                }
            }
        }

        public MemoryStream[] GetAnimMemStreamFromCurrentOrientation(byte orientation)
        {
            var b = new MemoryStream[4];
            
            for (int i = 0; i < 4; i++)
            {
                _animations[orientation, i].Save(b[i], ImageFormat.Png);
            }

            return b;
        }
    }
}
